package lv.accenture.jbcamp.ex08;

public class TestPrinter {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		
		Printer printer = Printer.getPrinter();
		
		Producer pr1 = new Producer(500, 4, "PRODUCER 1111", 3);
		Producer pr2 = new Producer(1000, 6, "PRODUCER 2222", 2);
		Producer pr3 = new Producer(1500, 3, "PRODUCER 3333", 6);
		
		Thread tPrinter = new Thread(printer);
		Thread tPr1 = new Thread(pr1);
		Thread tPr2 = new Thread(pr2);
		Thread tPr3 = new Thread(pr3);

		tPrinter.setPriority(Thread.MAX_PRIORITY);

		tPrinter.start();
		tPr1.start();
		tPr2.start();
		tPr3.start();
		
		try {
			tPr1.join();
			tPr2.join();
			tPr3.join();
		} catch (InterruptedException e1) {
			
		}
		
		printer.halt();
		System.out.println("\n\nAll producers finish thier work.");
		
	}

}
